function check_login() {
    var username=$("#user_name").val();
    var password=$("#password").val();
    if (username == '' || password == '') {
    /*
        $("#login_form").removeClass('shake_effect');
        setTimeout(function(){
            $("#login_form").addClass('shake_effect')
        },1);
    */
        alert("用户名或密码不能为空");
        return;
    }
    // 发送请求
    $.ajax({
        url: "http://127.0.0.1:8023/user/doLogin",
        type: "GET",
        dataType: "JSON",
        contentType: "application/x-www-form-urlencoded",
        /*crossDomain:true, //设置跨域为true
        xhrFields: {
            withCredentials: true //默认情况下，标准的跨域请求是不会发送cookie的
        },*/
        data: {
            username: username,
            password: password
        },
        success: function(res) {
            console.log(res);
            if (res.status.code != 1) {
                alert("用户名或密码错误！");
                return;
            }
            localStorage.setItem("satoken",res.result.tokenValue);
            // 登录成功跳转页面
            window.location.href = 'index.html';
        },
        /*error : function(e){
            alert("登录失败！");
        }*/
    });
    
}

$(function(){
    $("#create").click(function(){
        check_register();
        return false;
    })
    $("#login").click(function(){
        check_login();
        return false;
    })
    $('.message a').click(function () {
        $('form').animate({
            height: 'toggle',
            opacity: 'toggle'
        }, 'slow');
    });
})